<?php

namespace App\Console\Commands;

use App\Dao\CommonDao;
use App\Dao\UsersDao;
use Illuminate\Console\Command;

class User_Max_Recive_Price_Zero extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'user_max_recive_price_zero';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '检测用户最大收益为0并且释放所有积分';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //
        $query = UsersDao::builder_user_query()
            ->where('max_recive',0)
            ->where('vip_index_level',1)
            ->where('score','<>',0)
            ->where('user_id','<>',2);

        if(!$query->exists()){
            return;
        }
        $lists = $query->get()->toArray();
        foreach ($lists as $k=>$v){
            UsersDao::score_to_balance([
                'user_id'=>$v['user_id'],
                'nums'=>$v['score']
            ]);
        }
    }
}
